mudbox::ImgTile Class Reference

#include <image.h>

Inheritance diagram for mudbox::ImgTile:

Inheritance graph
[legend]
List of all members.

Detailed Description

Represents a rectangle. Used to specify rectangular regions of an image.

Public Member Functions

  ImgTile ()
  Create a default empty tile.
  ImgTile (int X, int Y, int NX, int NY)
  Create a tile as specified in the parameters.
  ImgTile (const ImgTile &a, const ImgTile &b)
  Construct a tile by computing the intersection fo the two input tiles.
bool  isEqualTile (const ImgTile &t) const
bool  operator== (const ImgTile &t) const
bool  operator!= (const ImgTile &t) const
bool  isEmpty () const
  return true of this tile is empty
void  setEmpty ()
bool  contains (const ImgTile &a) const
  return true if this tile includes the specified tile
bool  contains (int x_, int y_) const
  return true if this tile includes the specified point
void  clipPositive ()
  Clip the tile so it will not extend into the negative quadrants.
void  ExpandToInclude (int x_, int y_)
  Expand this tile to include the specified point.
void  Expand (int numPixels=1)
  Grow the tile by the specified number of pixels on all 4 sides.
int  numPixels () const
  return the number of pixels contained in this tile

Public Attributes

int  x
  x origin of the tile
int  y
  y origin of the tile
int  nx
  x size of the tile (width)
int  ny
  y size of the tile (height)

Constructor & Destructor Documentation

mudbox::ImgTile::ImgTile  )  [inline]
 

Create a default empty tile.

00924 : x(0), y(0), nx(0), ny(0) {}
mudbox::ImgTile::ImgTile int  X,
int  Y,
int  NX,
int  NY
[inline]
 

Create a tile as specified in the parameters.

Parameters:
X  X origin
Y  y Origin
NX  x Size (width)
NY  y Size (height)
00933 : x(X), y(Y), nx(NX), ny(NY) {}
mudbox::ImgTile::ImgTile const ImgTile a,
const ImgTile b
[inline]
 

Construct a tile by computing the intersection fo the two input tiles.

Parameters:
t1  First tile to be intersected
t2  Second tile to be intersected
00948     {
00949         x  = MAX(a.x, b.x);
00950         y  = MAX(a.y, b.y);
00951         nx = MIN(a.x+a.nx, b.x+b.nx) - x;
00952         ny = MIN(a.y+a.ny, b.y+b.ny) - y;
00953         if (nx <= 0 || ny <= 0) x = y = nx = ny = 0;
00954     }

Member Function Documentation

bool mudbox::ImgTile::isEqualTile const ImgTile t  )  const [inline]
 
00957     { return x == t.x && y == t.y && nx == t.nx && ny == t.ny; }
bool mudbox::ImgTile::operator== const ImgTile t  )  const [inline]
 
00960     { return x == t.x && y == t.y && nx == t.nx && ny == t.ny; }
bool mudbox::ImgTile::operator!= const ImgTile t  )  const [inline]
 
00963     { return !(t == *this); }
bool mudbox::ImgTile::isEmpty  )  const [inline]
 

return true of this tile is empty

00966 { return nx <= 0 || ny <= 0; }
void mudbox::ImgTile::setEmpty  )  [inline]
 
00968 { x = y = nx = ny = 0; }
bool mudbox::ImgTile::contains const ImgTile a  )  const [inline]
 

return true if this tile includes the specified tile

00972     { return x <= a.x && a.x+a.nx <= x+nx &&
00973              y <= a.y && a.y+a.ny <= y+ny;
00974     }
bool mudbox::ImgTile::contains int  x_,
int  y_
const [inline]
 

return true if this tile includes the specified point

00978     { return x <= x_ && x_ < x+nx && y <= y_ && y_ < y+ny;
00979     }
void mudbox::ImgTile::clipPositive  )  [inline]
 

Clip the tile so it will not extend into the negative quadrants.

00983     {
00984         if (x < 0) {
00985             nx += x; x = 0;
00986             if (nx < 0) x = y = nx = ny = 0;
00987         }
00988         if (y < 0) {
00989             ny += y; y = 0;
00990             if (ny < 0) x = y = nx = ny = 0;
00991         }
00992     }
void mudbox::ImgTile::ExpandToInclude int  x_,
int  y_
[inline]
 

Expand this tile to include the specified point.

00996     {
00997         if (isEmpty()) {
00998             x = x_; y = y_; nx = 1; ny = 1;
00999         } else {
01000             if (x_ < x) { nx += (x - x_); x = x_; }
01001             if (y_ < y) { ny += (y - y_); y = y_; }
01002 
01003             if (x + nx < x_) nx = (x_ - x) + 1;
01004             if (y + ny < y_) ny = (y_ - y) + 1;
01005         }
01006     }
void mudbox::ImgTile::Expand int  numPixels = 1  )  [inline]
 

Grow the tile by the specified number of pixels on all 4 sides.

01010     {
01011         x  -= numPixels; y  -= numPixels;
01012         numPixels <<= 1;
01013         nx += numPixels; ny += numPixels;
01014     }
int mudbox::ImgTile::numPixels  )  const [inline]
 

return the number of pixels contained in this tile

01017 { return isEmpty() ? 0 : nx * ny; }

Member Data Documentation

int mudbox::ImgTile::x
 

x origin of the tile

int mudbox::ImgTile::y
 

y origin of the tile

int mudbox::ImgTile::nx
 

x size of the tile (width)

int mudbox::ImgTile::ny
 

y size of the tile (height)


mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile
mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile mudbox::ImgTile